<template>
	<view class="wrapper">
		<view class="nodata tac fw" v-if="list.length==0">暂无资料，点击添加按钮去添加</view>
		<view class="listBar fz12" v-for="item in list" :key="item.id" @click="change(item.id)" v-if='id==7'>
      <view class="height-v">
        <view class="upBtn tac color-bs" v-if="ui<=0">修改</view>
      </view>
			<view class="height bd">
				<text>行业：</text>
				<text>{{item.industry}}</text>
			</view>
			<view class="height bd">
				<text>车辆状态：</text>
				<text>{{item.carState}}</text>
			</view>
			<view class="height bd">
				<text>座位数：</text>
				<text>{{item.carNumber}}</text>
			</view>
			<view class="height bd">
				<text>车辆动力：</text>
				<text>{{item.carPower}}</text>
			</view>
			<view class="height bd">
				<text>是否个人名下非营运：</text>
				<text>{{item.isOperation}}</text>
			</view>
			<view class="height bd">
				<text>职务：</text>
				<text>{{item.job}}</text>
			</view>
			<view class="height bd">
				<text>全款车目前市场价：</text>
				<text>{{item.totalPayment}}</text>
			</view>
			<view class="height bd">
				<text>剩余按揭本金：</text>
				<text>{{item.oddCorpus}}</text>
			</view>
			<view class="height">
				<text>创建时间：</text>
				<text>{{getTime(item.createTime)}}</text>
			</view>
		</view>
		<view class="listBar fz12" v-for="item in list" :key="item.id" @click="change(item.id)" v-if='id!=7'>
      <view class="height-v">
        <view class="upBtn tac color-bs" @click="">修改</view>
      </view>
			<view class="top height bd disb aic">
				<view class="" v-if="item.oneOrTwo">
					<text>首套房或者二套房：</text>
					<text>{{item.oneOrTwo}}</text>
				</view>
				<view class="" v-if="item.ownership">
					<text>所有权：</text>
					<text>{{item.ownership}}</text>
				</view>
				<view class="">
					<text>所在区域：</text>
					<text>{{item.area}}</text>
				</view>
			</view>
			<view class="height bd">
				<text>土地类型：</text>
				<text>{{item.landTypes}}</text>
			</view>
			<view class="height bd">
				<text>房屋结构：</text>
				<text>{{item.buildingStructure}}</text>
			</view>
			<view class="height bd">
				<text>房屋类型：</text>
				<text>{{item.houseType}}</text>
			</view>
			<view class="height bd">
				<text>建筑面积：</text>
				<text>{{item.areaOfStructure}}</text>
			</view>
			<view class="height bd" v-if="item.mortgageTime">
				<text>按揭时间：</text>
				<text>{{item.mortgageTime}}</text>
			</view>
			<view class="height bd" v-if="item.loanAmount">
				<text>贷款金额：</text>
				<text>{{item.loanAmount}}</text>
			</view>
			<view class="height bd" v-if="item.oddCorpus">
				<text>剩余本金：</text>
				<text>{{item.oddCorpus}}</text>
			</view>
			<view class="height bd" v-if="item.cellName">
				<text>小区名字：</text>
				<text>{{item.cellName}}</text>
			</view>
			<view class="height">
				<text>创建时间：</text>
				<text>{{getTime(item.createTime)}}</text>
			</view>
		</view>
		<view class="Btn tac colorf" @click="add" v-if="ui<=0">添加</view>
	</view>
</template>

<script>
	import {
		getHouseList,
		getMortgagingHousingList,
		getResidentialMortgageList,
		getResidentialMortgageTwoList,
		getCarList,getOfficeBuildingList,
		getOfficeBuildingTwoList,
		getCommercialBuildingMortgageList,
		} from "../../api/information.js"
	export default {
		data() {
			return {
				id:null,
        ui:0,
				list:[]
			};
		},
		onLoad(option) {
			this.id = option.id
      if (option.ui!=null && option.ui!=undefined && option.ui!='') {
        this.ui = option.ui
      }
		},
		onShow() {
			this.getList()
		},
		methods:{
			getList(){
				if(this.id==7){
					getCarList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==1){
					getHouseList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==8){
					getOfficeBuildingList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==9){
					getOfficeBuildingTwoList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==10){
					getCommercialBuildingMortgageList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==14){
					getMortgagingHousingList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==15){
					getResidentialMortgageList(this.ui).then(res => {
						this.list = res.data
					})
				} else if(this.id==16){
					getResidentialMortgageTwoList(this.ui).then(res => {
						this.list = res.data
					})
				}
			},
			//添加
			add(){
				uni.navigateTo({
					url:`/pagesA/list/carInformation?id=${this.id}`
				})
			},
			//修改
			change(ids){
        console.log(ids)
				uni.navigateTo({
					url:`/pagesA/list/carInformation?id=${this.id}&listId=${ids}`
				})
			},
			//时间戳转换
			getTime(time){
				let data= new Date(time);
				let year = data.getFullYear();
				let month = data.getMonth() + 1;
				let day = data.getDate();
				let h = data.getHours();
				let mm = data.getMinutes();
				let s = data.getSeconds();
				month = month >= 10 ? month : "0" + month;
				day = day >= 10 ? day : "0" + day;
				h = h >= 10 ? h : "0" + h;
				mm = mm >= 10 ? mm : "0" + mm;
				s = s >= 10 ? s : "0" + s;
				return `${year}-${month}-${day} ${h}:${mm}:${s}`;
			},
		}
	}
</script>

<style lang="scss">
.wrapper{
	padding: 20rpx;
	background-color: #f7f7f7;
	min-height: 100vh;
	.nodata{
		padding: 40rpx;
	}
	.listBar{
		padding: 20rpx 30rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		.bd{
			border-bottom: 1rpx solid #d9d9d9;
		}
		.height{
			padding: 10rpx 0;
		}
	}
	.Btn{
		line-height: 80rpx;
		border-radius: 40rpx;
		background-color: #3F51B5;
	}
}

.upBtn{
  width: 20%;
  line-height: 50rpx;
  border-radius: 4rpx;
  float: right;
  background-color: #f3f3f3;
}
.height-v{
  height: 20px;
}
</style>
